/**
 * wait使用
 */
public class WaitDemo {
    public static void main(String[] args) {
        Object lock=new Object();
        Thread t1=new Thread(()->{
            System.out.println("线程1开始执行");
            try {
               synchronized (lock){
                   System.out.println("线程1调用wait方法...");
                   //无限期的等待状态
                   lock.wait();
               }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("线程1执行完成");
        },"线程1");
        t1.start();
    }
}
